package com.denjiawen.project01;

import com.dengjiawen.project01.bag.impl.MyObjectListImpl;
import com.dengjiawen.project01.util.FileUtil;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author Jarvan
 * @version 1.0
 * @create 2020/9/23 8:39
 */
public class ObjectTest01 {
    /**
     * Test the size of the MyObject List.
     */
    @Test
    public void testSize() {
        MyObjectListImpl myObjectList = new MyObjectListImpl();
        System.out.println(myObjectList.size());
    }

    /**
     * Test remove exception success.
     */
    @Test
    public void testRemoveException() {
        MyObjectListImpl myObjectList = new MyObjectListImpl();
        System.out.println(myObjectList.removeLast());

    }

    /**
     * Test removeRandom
     */
    @Test
    public void removeRandomTest() {
        MyObjectListImpl myObjectList = new MyObjectListImpl();
        for (int i = 0; i < 5; i++) {
            myObjectList.insert("object_" + (i));
        }
        System.out.println("before remove size()=" + myObjectList.size());
        Object o = myObjectList.removeRandom();
        System.out.println("=============");
        System.out.println("remove object=" + o);
        System.out.println("after remove size()=" + myObjectList.size());
        System.out.println("======loop sout======");
        for (int i = 0; i < myObjectList.size(); i++) {
            System.out.println(myObjectList.getList()[i]);
        }
        ArrayList<Integer> arrayList = new ArrayList<>();

    }

    /**
     * path Testing.
     */
    @Test
    public void pathTesting() throws IOException {
        String s = FileUtil.readFileAsString("data.txt");
        System.out.println(s);
        String[] split = s.split("\\n");
        for (String s1 : split) {
            System.out.println("item=" + s1);
        }
    }
}
